<template>
	<view class="goodsList">
		<view class="readList" v-for="(item,index) in list" :key='index' @click="enterDetail(item)">
			<view class="left ">
				<image :src="item.picPosition[0]" mode="widthFix"></image>
			</view>
			<view class="right">
				<text>{{item.goodsName}}  
					<text v-if="item.goodsStatus===1" style="color: #FF9900; margin-left: 20rpx;">已售罄</text>
					<text v-else style="color: #FF9900; margin-left: 20rpx;"> 库存 {{item.goodsNum}}</text>
				 </text> 
				<view class="disc">
					<text> {{item.goodsContent}}</text>
				</view>
				
				<view class="">
					<text style="color: #ff0000; font-size: 32rpx; font-weight: 400;">￥<text >{{item.goodsPrice}} 元</text></text>
				</view>
				<view class="footTxt">
					<view class="font12">
						
					</view>
					<view class="butt"  >
						<text v-show="item.num===1" v-on:click.stop="addCard(item)">加入购物车</text>
						<!-- <view v-show="item.num>=1" class="" style="display: flex; flex-direction: row;">
							<view class="" style="border: 1rpx solid #ccc; width: 40rpx; height: 40rpx; line-height: 36rpx; text-align: center;">
								<text @click="cardDel(item)">-</text>
							</view>
							<view class="" style="border: 1rpx solid #ccc; width: 60rpx; height: 40rpx; line-height: 36rpx; text-align: center;">
								<text>{{item.num}}</text>
							</view>
							<view class="" style="border: 1rpx solid #ccc; width: 40rpx; height: 40rpx; line-height: 36rpx; text-align: center;">
								<text @click="cardAdd(item)">+</text>
							</view>
						</view> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		props:{
			list:Array,
			required:true
		},
		data() {
			return {
				animationData: {},
			}	
		},
		computed: {
			
			
		},
		mounted() {
			let animation=uni.createAnimation({
				duration: 1000,
				timingFunction: 'ease',
			})
			this.animation=animation
		},
		methods: {
			addCard(it){
				console.log(it)
				if(it.num<it.goodsNum){
					uni.showToast({
						title:'加入成功',
						
					})
					this.add(it)
				}else{
					uni.showToast({
						title:'购买数量超出库存数量',
						icon:'none'
					})
				}
				
				
				
			},
			enterDetail(it){
				console.log("外层")
				uni.navigateTo({
					url:'../enter/detail?id='+it.goodsId
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.readList{
		width: 100%;
		height: 240rpx;
		margin-bottom: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		.left{
			width: 180rpx;
			height: 240rpx;
			
			margin-right: 20rpx;
			overflow: hidden;
			display: flex;
			flex-direction: column;
			justify-content: center;
			background-color:#fff ;
			
			image{
				width: 180rpx;
			}
		}
		.right{
			width: 500rpx;
			height: 240rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			align-items: flex-start;
			.disc{
				font-size: 30rpx;
				color: #4D4C4C;
				width: 100%;
				height: 90rpx;
				line-height: 46rpx;
				 text-overflow: -o-ellipsis-lastline;
				  overflow: hidden;
				  text-overflow: ellipsis;
				  display: -webkit-box;
				  -webkit-line-clamp: 2;
				  line-clamp: 2;
				  -webkit-box-orient: vertical;
			}
			.footTxt{
				width: 100%;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				.font12{
					font-size: 20rpx;
					color: #ccc;
				}
				.butt{
					width: 140rpx;
					height: 36rpx;
					border: 2rpx solid #19BE6B;
					text-align: center;
					line-height: 30rpx;
					font-size: 22rpx;
					color: #4CD964;
				}
			}
		}
	}
</style>
